package com.jinkaimen.goodcash.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.ht.baselibs.retrofit.NetCallBack;
import com.ht.baselibs.ui.activity.SelectListActivity;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.SharedPreferencesUtils;
import com.ht.baselibs.utils.UIUtils;
import com.jinkaimen.goodcash.R;
import com.jinkaimen.goodcash.bean.AuUserBean;
import com.jinkaimen.goodcash.bean.BizShopBean;
import com.jinkaimen.goodcash.bean.KeyAndValueBean;
import com.jinkaimen.goodcash.bean.ReportRegisterGetBean;
import com.jinkaimen.goodcash.bean.SearchShopBean;
import com.jinkaimen.goodcash.constant.ConstantPool;
import com.jinkaimen.goodcash.manager.ApiManager;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Response;

public class RegisterNewActivity extends BaseActivity {

    private TextView mTelView;
    private TextView mSettleTypeView;
    private TextView mShopNameView;
    private long mUserId;
    private boolean canEdit;
    private long mShopId;
    private String mAddress;
    private TextView mAddressView;

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("商铺资料");
    }

    @Override
    protected void initIntentData(Intent callIntent) {
        mUserId = callIntent.getLongExtra("report_account_id", 0);
        canEdit = callIntent.getBooleanExtra("canEdit", true);
        mShopId = callIntent.getLongExtra("report_shop_id", 0);
        mUserId = callIntent.getLongExtra("report_user_id", 0);
        mAddress = callIntent.getStringExtra("report_user_address");
    }

    @Override
    protected int initContentView() {
        return R.layout.activity_register_new;
    }

    @Override
    protected void initChildView() {
        mShopNameView = (TextView) findViewById(R.id.et_activity_register_shop_name);
        mSettleTypeView = (TextView) findViewById(R.id.tv_activity_register_industory);
        mTelView = (TextView) findViewById(R.id.et_activity_register_tel);
        mAddressView = (TextView) findViewById(R.id.et_activity_register_tel_new);
    }

    @Override
    protected void initChildData() {
        mAddressView.setText(mAddress);
        if (mShopId == 0) {
            return;
        }
        showLoadingDialog();
        ApiManager.getApi().searchShopInfo(
                "INV_HSY001010",
                mUserId
        ).enqueue(new NetCallBack<SearchShopBean>() {
            @Override
            protected void onSuccess(Call<SearchShopBean> call, Response<SearchShopBean> response) {
                BizShopBean bizShopBean = new BizShopBean();
                AuUserBean auUserBean = new AuUserBean();
                try {
                    bizShopBean = response.body().appBizShop;
                    auUserBean = response.body().appAuUser;
                } catch (Exception e) {
                    e.printStackTrace();
                }
                String cellphone = auUserBean.cellphone;
                String shopName = bizShopBean.name;
                String industryName = bizShopBean.industryName;
                mShopNameView.setText(shopName);
                mSettleTypeView.setText(industryName);
                mTelView.setText(cellphone);
            }


            @Override
            protected boolean isNullNeedCallback() {
                return true;
            }

            @Override
            protected void hiddenProgress() {
                hideLodingDialog();
            }
        });
    }

    @Override
    protected void setChildViewListener() {

    }


}
